package com.chen.demo.javase.jvm;

import java.lang.ref.WeakReference;

/**
 * @author chenhongwei
 * @date 2020/2/28 21:00
 **/
public class WeakReferenceTest {
    public static class User{

    }

    /**
     * -Xms10m -Xmx10m -XX:+PrintGC
     * @param args
     */
    public static void main(String[] args) {
        User u  = new User();
        WeakReference<User> weakReference = new WeakReference(u);
        u = null;
        System.out.println("********:"+weakReference.get());
        System.gc();
        System.out.println("aftergc,********:"+weakReference.get());

    }
}
